package com.lzh.chatnote.chat.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * Description: 幂等类型
 */
@AllArgsConstructor
@Getter
public enum GroupMemberStatusEnum {

    //在线状态 1在线 2离线
    ONLINE(1, "在线"),
    OFFLINE(2, "离线");
    private final Integer activeStatus;
    private final String desc;

    private static Map<Integer, GroupMemberStatusEnum> cache;

    static {
        cache = Arrays.stream(GroupMemberStatusEnum.values()).collect(Collectors.toMap(GroupMemberStatusEnum::getActiveStatus, Function.identity()));
    }

    public static GroupMemberStatusEnum of(Integer type) {
        return cache.get(type);
    }
}
